import unittest
from time import sleep
from selenium import webdriver
from ddt import ddt, data, unpack, file_data
from selenium.webdriver.common.by import By


@ddt
class Test(unittest.TestCase):
    # 前置
    def setUp(self) -> None:
        self.wd = webdriver.Chrome()
        self.wd.get("https://scitc.fanya.chaoxing.com/portal")
        self.wd.find_element(By.CSS_SELECTOR, ".loginSub").click()

    # 后置
    def tearDown(self) -> None:
        self.wd.quit()
 
    # ------------------------------------------------------------
    # @data(["19150979228", "CXR19150979228"],["111","1111"])
    # @unpack
    @file_data('../data/user.yaml')
    def test1(self, **kwargs):
        # print(kwargs)
        # print(kwargs['name'])
        self.wd.implicitly_wait(5)
        self.wd.find_element(By.CSS_SELECTOR, "#phone").send_keys(kwargs["name"])
        self.wd.find_element(By.CSS_SELECTOR, ".ipt-pwd").send_keys(kwargs["mima"])
        self.wd.find_element(By.CLASS_NAME, "btn-big-blue").click()
        sleep(3)

    # def test2(self):
    #     self.wd.find_element(By.CSS_SELECTOR, "#phone").send_keys('18125703598')
    #     self.wd.find_element(By.CSS_SELECTOR, ".ipt-pwd").send_keys('CXR19150979228')
    #     self.wd.find_element(By.CLASS_NAME, "btn-big-blue").click()
    #     sleep(3)


if __name__ == '__main__':
    unittest.main()

# T=Test()
# T.open()
# T.test1()
# T.test2()
# T.close()
